<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
				<script src="../js/jquery/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
				<script src="../assets/layui-v2.4.5/layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="../assets/layui-v2.4.5/layui/css/layui.css" />
 

		   <script>
			    $(function () {  //, headers: { 'x-requested-with': 'XMLHttpRequest' }
			        $.ajaxSetup({crossDomain: true, xhrFields: {withCredentials: true}});
			    });
	</script>
	
	<script type="text/javascript">
		$(function(){
			
			
					layui.use(['form', 'layedit', 'laydate','element'], function() {
					var form = layui.form,
						layer = layui.layer,
						layedit = layui.layedit, 
						laydate = layui.laydate;

				});
			
			
//			alert(localStorage.getItem("money"))
//			alert(localStorage.getItem("pkg_id"))
			
			
		})
		
		
		
			var n = 3;

			function showTime() {
				
				

				layui.use('layer', function() {
					var $ = layui.jquery,
					layer = layui.layer;
					n--;
					$('#divMain').html(n + ' 秒后关闭窗口');
					if(n == 0) {
						var index = parent.layer.getFrameIndex(window.name);
//						alert(index)
						parent.layer.close(index);
						$.ajax({
								type:"get",
								url:"http://127.0.0.1:8099/pay/alipay",
								data:"payAmount="+localStorage.getItem("money")+"&pkgId="+localStorage.getItem("pkg_id"),
								async:true,
								success:function(data){ 
				//					alert(data) 
				//					showTime() 
								}
			});
					} else {
						setTimeout('showTime()', 1000);
					}
				})

			}
	</script>
	</head>
	<body onload="showTime()">
		
		 
		支付成功
		<form id="form1" runat="server">
	    <div id ="divMain" class ="main" >
	
	    </div>
	    </form>
		
	</body>
</html>
